8226baecc27a82f5c4d83606eccb054a12167ddf,src/test/java/jp/vmi/selenium/testutils/WebServer.java,WebServer,start,#,91

Before Change


    public void start() {
        port = PortProber.findFreePort();
        File htdocs = FileUtils.toFile(getClass().getResource("/htdocs"));
        server = WebServers.createWebServer(port)
            .add("/form_posted\\.html", new FormPosted())
            .add(new SimpleTemplateHandler(htdocs))
            .add("/basic", new BasicAuthenticationHandler(new InMemoryPasswords().add("user", "pass")))
            .add("/redirect", new RedirectHandler("http://" + getServerNameString() + "/index.html"))
            .add("/basic/redirect", new RedirectHandler("http://" + getServerNameString() + "/basic/index.html"));
        try {
            server.start().get();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {

After Change


     * Start web server.
     */
    public synchronized void start() {
        InetSocketAddress sock = new InetSocketAddress(fqdn, port);
        try {
            server = HttpServer.create(sock, 0);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        server.createContext("/", new SimpleTemplateHandler(htdocs));
        //server.createContext("/basic", new BasicAuthenticationHandler(new InMemoryPasswords().add("user", "pass")));
        //server.createContext("/redirect", new RedirectHandler("http://" + getServerNameString() + "/index.html"));
        //server.createContext("/basic/redirect", new RedirectHandler("http://" + getServerNameString() + "/basic/index.html"));
        shutdownHook = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (WebServer.this) {
                    shutdownHook = null;
                    if (server != null) {
                        System.err.println();
                        stop();
                    }
                }
            }
        });
        Runtime.getRuntime().addShutdownHook(shutdownHook);
        server.start();
        log.info("Started.");
    }